// pages/housekeeping/housekeepng.js
var util = require("../../utils/util.js")
Page({
  data: {
    //轮播图
    imgUrls: [
      'http://1.aiym.applinzi.com/images/scroll1.jpg',
      'http://1.aiym.applinzi.com/images/scroll2.jpg',
      'http://1.aiym.applinzi.com/images/scroll3.jpg'
    ],
    indicatorDots: true,
    autoplay: true,
    interval: 5000,
    duration: 1000,
    longitude: '',
    latitude: '',
    formatted_address: '',
    grids: [],
    more: [{
      content: "更多",
      fid: "1",
      imgurl: "../../images/moreBox.png"
    }],
    hasOrder:''
  },
  onLoad: function (options) {
    var that = this;
    // console.log(options)
    //获取显示数据
    wx.request({
      url: "http://1.aiym.applinzi.com/aiyouwai.php",
      data: {
        type: "firstPage",
      },
      header: { "content-type": "application/json" },
      success: function (res) {
        wx.setStorage({
          key: 'nameTitle',
          data: res.data[0].content,
        })
        that.setData({
          grids: res.data
        })
      }
    })
    // // 添加位置坐标
    // wx.getLocation({
    //   type: 'gcj02', // 默认为 wgs84 返回 gps 坐标，gcj02 返回可用于 wx.openLocation 的坐标
    //   success: function (res) {
    //     var longitude = res.longitude
    //     var latitude = res.latitude
    //     that.setData({
    //       longitude: res.longitude,
    //       latitude: res.latitude
    //     });
    //   }
    // })
  },


  // 设置点击事件
  click: function (event) {
        console.log(this.data.hasOrder)
    // 设置点击之后传输的经纬度
    var id = event.currentTarget.dataset.url;
    var name = this.data.grids[0].content;

    // console.log(name);
    // console.log(id)
    wx.navigateTo({
      url: '../server/server?ID=' + id + '&name=' + name + '&latitude=' + this.data.latitude + '&longitude=' + this.data.longitude,
    })
  },
  onShow: function () {
    // 页面显示
   
  },
})